package com.sunfeng.n7;

import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;

/**
 * @author sunfeng    Alt+Shift+M   抽出方法
 * @date 2021/04/15 10:43
 **/

@Slf4j(topic = "c.Test11")
public class Test11 {
    public static void main(String[] args) {
       // test();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        for (int i = 0; i < 15; i++) {
            new Thread(() -> {
            TemporalAccessor temporalAccessor = dateTimeFormatter.parse("2021-04-01");
            System.out.println(temporalAccessor);
            }).start();
        }
    }

    private static void test() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                synchronized (simpleDateFormat) {
                    try {
                        log.debug("{}", simpleDateFormat.format(new Date()));
                    } catch (Exception e) {
                        log.error("{}", e.toString());
                    }

                }
            }).start();
        }
    }
}
